package com.yl.zqy.service.impl;

import cn.dev33.satoken.stp.StpInterface;
import com.yl.zqy.service.sys.SysMenuService;
import com.yl.zqy.service.sys.SysRoleService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Description 自定义权限加载接口实现类
 * @Author liang.yu
 * @Date 2024/4/10 22:34
 */
@Component
@AllArgsConstructor
@Slf4j
public class StpInterfaceImpl implements StpInterface {
    private final SysRoleService roleService;
    private final SysMenuService menuService;

    @Override
    public List<String> getPermissionList(Object loginId, String loginType) {
        List<String> userByMenusPermission = menuService.getUserByMenusPermission(loginId.toString());
        log.info("当前用户角色下拥有的权限集合：{}", userByMenusPermission);
        return userByMenusPermission;
    }

    @Override
    public List<String> getRoleList(Object loginId, String loginType) {
        List<String> userByRole = roleService.getUserByRole(loginId);
        log.info("当前用户角色：{}", userByRole);
        return userByRole;
    }
}
